﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GNSCore.Repositories;
using GNSCore.Model.Context;
using GNSCore.Repositories.IOC;
using GNSCore.Model;
using GNSCore.Managers;

namespace GNSCore.Helpers
{
    /// <summary>
    /// For accessing user settings
    /// </summary>
    public class UserSettingsHelper
    {
        static IRepository<UserSettings> _settingsRepository;

        static IGNSContext _context;

        static UserSettingsHelper()
        {
            _settingsRepository = IOCManager.IOCContainer.Resolve<IRepository<UserSettings>>();
            _context = IOCManager.IOCContainer.Resolve<IGNSContext>();
            _settingsRepository.SetContext(_context);
        }

        /// <summary>
        /// Loads user's settings by his name
        /// </summary>
        /// <param name="username">User's name</param>
        /// <returns>User specefied settings</returns>
        public static UserSettings LoadUserSettings(string username)
        {
            SettingsManager settingsManager = new SettingsManager(_settingsRepository);
            return settingsManager.GetUserSettings(username);
        }
    }
}
